package com.huawei.appgallery.assistantdock.buoydock.webview.delegate;

import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.agwebview.api.delegate.GeneralWebViewDelegate;
import com.huawei.appgallery.agwebview.api.ui.IWebViewActivityProtocol;
import com.huawei.appgallery.assistantdock.base.externalaction.openviewaction.NetConfigAction;
import com.huawei.appgallery.assistantdock.buoydock.uikit.window.WindowRelativeLayout;
import com.huawei.appgallery.assistantdock.buoydock.uikit.window.WindowRelativeLayout.b;
import com.huawei.appgallery.assistantdock.buoydock.webview.request.BuoyWebViewWindowRequest;
import com.huawei.gamebox.plugin.gameservice.view.TransferActivity;
import java.util.LinkedHashMap;
import o.azj;
import o.azp;
import o.bab;
import o.beo$b;
import o.beo$e;
import o.beo$j;
import o.beo.f;
import o.bht;
import o.Logger;
import o.dof;
import o.enx;
import o.epr;
import o.ezn;
import o.fal;
import o.fam;
import o.fbp;
import o.fho;

public class BigBuoyWebviewDelegate extends GeneralWebViewDelegate {
    protected LinearLayout ʾ;
    protected TextView ˈ;
    private View ˊᐝ;
    private String ˋˊ = null;

    public void ˎ(View view) {
        this.ʾ = (LinearLayout) view.findViewById(beo$e.ͺˎ);
        this.ˈ = (TextView) view.findViewById(beo$e.ˑॱ);
        this.ʻ = (ProgressBar) view.findViewById(beo$e.ʽ);
        this.ʼ = (WebView) view.findViewById(beo$e.ˋ);
        this.ᐝ = (LinearLayout) view.findViewById(beo$e.ٴ);
        if (view instanceof WindowRelativeLayout) {
            ((WindowRelativeLayout) view).setOnKeyBackEvent(new b(this) {
                final /* synthetic */ BigBuoyWebviewDelegate ˋ;

                {
                    this.ˋ = r1;
                }

                public void ˊ() {
                    this.ˋ.ॱˊ();
                }
            });
        }
    }

    public boolean ˊ(Context context, IWebViewActivityProtocol iWebViewActivityProtocol) {
        if (!super.ˊ(context, iWebViewActivityProtocol) || !(iWebViewActivityProtocol instanceof BuoyWebViewWindowRequest)) {
            return false;
        }
        this.ˋˊ = ((BuoyWebViewWindowRequest) iWebViewActivityProtocol).getTitle();
        return true;
    }

    public void ˋ(Context context, String str, int i) {
        ezn.ˊ().ॱ(str, i);
    }

    public int ʻ() {
        return beo$j.ᐝॱ;
    }

    public void ˎ() {
        try {
            this.ˊᐝ = this.ʾ.findViewById(beo$e.ˎˏ);
            ʻ(this.ॱॱ.getUrl());
            if (this.ˋˊ != null) {
                this.ˈ.setText(this.ˋˊ);
            }
            this.ˊᐝ.setOnClickListener(new OnClickListener(this) {
                final /* synthetic */ BigBuoyWebviewDelegate ˎ;

                {
                    this.ˎ = r1;
                }

                public void onClick(View view) {
                    this.ˎ.ॱˊ();
                }
            });
        } catch (Throwable e) {
            Logger.ˋ("BigBuoyWebviewDelegate", "initTitle error", e);
        }
    }

    public void ˋ() {
        super.ˋ();
        this.ʼ.setBackgroundColor(ˏॱ().getResources().getColor(beo$b.ˎ));
        this.ʼ.setOnKeyListener(new OnKeyListener(this) {
            final /* synthetic */ BigBuoyWebviewDelegate ॱ;

            {
                this.ॱ = r1;
            }

            public boolean onKey(View view, int i, KeyEvent keyEvent) {
                if (i != 4 || keyEvent.getAction() != 1) {
                    return false;
                }
                this.ॱ.ॱˊ();
                return true;
            }
        });
        ˋᐝ();
    }

    public String ॱॱ() {
        if (this.ʼॱ != null) {
            return this.ʼॱ.ˎ();
        }
        return super.ॱॱ();
    }

    public void ˊ(String str) {
        String str2 = this.ˋˊ;
        if (!dof.ˋ(str2)) {
            str = str2;
        } else if (!"*#title*#".equals(str)) {
            if (dof.ˋ(str)) {
                str = ˏॱ().getString(f.ˊ);
            }
        } else {
            return;
        }
        this.ˈ.setText(str);
    }

    public void ʻ(String str) {
        this.ˊᐝ.setVisibility(0);
    }

    public void ॱᐝ() {
        fam.ॱ().ˊ(ˏॱ());
    }

    public boolean ˊ() {
        return false;
    }

    protected void ˋᐝ() {
        RelativeLayout relativeLayout = (RelativeLayout) this.ᐝ.findViewById(beo$e.ˊʻ);
        LayoutParams layoutParams = (LayoutParams) relativeLayout.getLayoutParams();
        layoutParams.addRule(15);
        relativeLayout.setLayoutParams(layoutParams);
    }

    public void ˏ() {
        this.ᐝ.findViewById(beo$e.ˋʼ).setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ BigBuoyWebviewDelegate ˋ;

            {
                this.ˋ = r1;
            }

            public void onClick(View view) {
                Intent intent = new Intent(this.ˋ.ˊ, TransferActivity.class);
                intent.setAction(NetConfigAction.ACTION_NET_CONFIG);
                fam.ॱ().ˎ(this.ˋ.ˊ, TransferActivity.class, intent, true);
            }
        });
    }

    public void ˎ(Object obj) {
        if (obj instanceof fbp) {
            ((fbp) obj).setFromBuoy(true);
        }
    }

    public String ʾ() {
        return "BigBuoyWebviewDelegate";
    }

    public LinkedHashMap ॱˎ() {
        LinkedHashMap linkedHashMap = new LinkedHashMap(4);
        if (epr.ˎ().ˏ() != null) {
            linkedHashMap.put("third_id", epr.ˎ().ˏ());
        }
        linkedHashMap.put("page_id", enx.ॱ(this.ॱᐝ));
        linkedHashMap.put("service_type", Integer.valueOf(4));
        linkedHashMap.put("user_agent", ॱॱ().trim());
        return linkedHashMap;
    }

    public bab ˋˊ() {
        return new bht();
    }

    public void ˋॱ() {
        if (this.ʼ == null || this.ʼ.getUrl() == null || azp.ॱ != ((azj) fho.ˏ().ˋ("AGWebView").ॱ(azj.class)).ˏ(this.ʼ.getUrl())) {
            super.ˋॱ();
        } else {
            fam.ॱ().ˊ(ˏॱ());
        }
    }

    public void ˎ(Context context, String str, String str2) {
        fal.ˊ().ˊ(context, str2);
    }
}
